Skip to content

feat(options): add option to disable the Server-Timing header - #921

Open
arjun-rajappa wants to merge 2 commits into
mainfrom
feat/disable-server-timing-option
Open

arjun-rajappa wants to merge 2 commits into
mainfrom
feat/disable-server-timing-option

Conversation

@arjun-rajappa

Copy link
Copy Markdown
Contributor

Why

Some users do not want the Instana Server-Timing header (intid;desc=<trace id>) added to their responses and outgoing requests. This adds a documented switch to turn it off, following the same configuration precedence as the other tracing options.

What

  • Add disable_server_timing to BaseOptions (default False). Precedence: INSTANA_TRACING_DISABLE_SERVER_TIMING > INSTANA_CONFIG_PATH YAML (tracing.global.disable-server-timing) > agent config > default. The agent config is applied in StandardOptions._apply_agent_disable_server_timing().
  • Add get_disable_server_timing_from_yaml() in util/config.py. It supports the deprecated com.instana.tracing root and tolerates an empty tracing: section.
  • Add BasePropagator.is_server_timing_disabled(). It reads the flag on every call, so runtime agent-config changes are honoured. It falls back to enabled and logs at debug level if the agent is unavailable.
  • HTTPPropagator, TextPropagator, BinaryPropagator and lambda_inst.py skip the header when the flag is set. The Lambda status-code handling is unchanged. The header logic moved into an add_server_timing_header() helper.
  • In TextPropagator and BinaryPropagator, build the headers once and write them per carrier type, instead of repeating if server_timing: in every branch. Injected headers and their order are unchanged.
  • Tests:
    • Options, YAML config reader and is_server_timing_disabled().
    • HTTP, binary and new text propagator tests.
    • New tests/instrumentation/aws/test_lambda_inst.py with a mocked agent.

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
@arjun-rajappa
arjun-rajappa requested a review from a team as a code owner November 9, 2026 05:53

@CagriYonca CagriYonca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of comments. What do you think?

Comment thread src/instana/options.py Resolved
Comment thread src/instana/options.py Resolved

@pvital pvital left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it looks good to me - just a few comments based on @CagriYonca's review.

Signed-off-by: Arjun Rajappa <arjun.rajappa@ibm.com>
@arjun-rajappa

Copy link
Copy Markdown
Contributor Author

Addressed all review comments: type hints, import ordering, test YAML fixtures plus tests for them, caplog assertion and test names. Kept the is_server_timing_disabled() placement as discussed with @pvital. @CagriYonca could you take another look?

@CagriYonca CagriYonca left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants